import * as THREE from "three"
import initRenderer from "./initRenderer.js";
import initScene from "./initScene.js";


class MyThree {
  // 场景
  scene;
  // 相机
  camera;
  // 渲染器
  renderer;
  // dom
  container;
  // 控制器
  controls;

  constructor(container) {
    this.container = container;
    this.scene = new THREE.Scene();
    this.init();
  }
  init() {
    // 初始化渲染器、相机、控制器
    let { renderer, camera, controls, render } = initRenderer({ scene: this.scene, container: this.container })
    this.renderer = renderer;
    this.camera = camera;
    this.controls = controls;
    this.renderer.setClearColor("black");
    // 初始化场景
    initScene({ scene: this.scene, container: this.container, renderer: this.renderer, camera: this.camera });

    // 开始渲染
    render();
  }
}

export default MyThree;
